﻿/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleAbstract
{
    //接口是用来实现的，而抽象类主要是用来使用父类的实现方法，否则就用接口吧！
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now.ToString("yyyy.MM.dd HH:mm"));
            //Random r = new Random(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0));
            //for(int i=0; i<10000 ;i++)
            //{
            //    string num = DateTime.Now.ToString("yyMMdd") + r.Next(100000, 1000000).ToString();
            //    WriteString(num);
            //}
            //List<int> list=new List<int>();
            //if (!list.Any())
            //{
            //    string b = "";
            //}

          //  Dictionary<Int32, string> dicNew = new Dictionary<int, string>();
            //dicNew.Add(3, "adfg");
            //dicNew.Add(5, "adf3");
            //dicNew.Add(6, "adf4");
            //dicNew.Add(7, "adf5");

           // KeyValuePair<Int32, string> pair = dicNew.FirstOrDefault();
          //  Console.WriteLine(dicNew.Values.FirstOrDefault()??"0");
            //ArrayList arlist = new ArrayList();
            //for (int i = 0; i <= 8; i++)
            //{
            //    arlist.Add(i);
            //}
            //IEnumerator enumer = arlist.GetEnumerator(2, 5);//这句返回从第二个元素起,找5个元素.结果为 2,3,4,5,6.如果此处换为GetEnumerator(),则返回所有

            //while (enumer.MoveNext()) //一定要先movenext,不然会有异常
            //{
            //    Console.WriteLine(enumer.Current.ToString());
            //}
            //Console.ReadLine();

           // Console.WriteLine("X={0},Y={1}", A.X, B.Y);

            //Nokia m = new Nokia();
            //m.c = "c";
            //m.ChangeStr(m);
            //Console.WriteLine(m.c);
            //m.Call();
            //m.Callagain();
            //m.Callvirtual();
            //m.Print("test");
            //m.GetMobileType();
            //Xiaomi x = new Xiaomi();
            //x.Print("xiaomi");
            Console.WriteLine("生成完成！");
            Console.ReadLine();

        }
       public static void WriteString(string Str)
        {
            string FileAddress = @"C:/Log.txt";
            FileStream fs = null;
            if (!System.IO.File.Exists(FileAddress))
            {
                fs = new FileStream(FileAddress, FileMode.Create);
            }
            else
            {
                fs = new FileStream(FileAddress, FileMode.Append);
            }
            StackTrace st = new StackTrace(true);
            string transferMethod = st.GetFrame(1).GetMethod().Name.ToString();

            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(Str + "\r\t");
            sw.Close();
        }
    }

    /// <summary>
    /// 抽象类
    /// </summary>
    public abstract class MobilePhone
    {
        public string Type { get; set; }
        public abstract void Call();

        public virtual void Callagain()
        {
            Console.WriteLine("virtual Callagain! ");
        }

        public virtual void Callvirtual()
        {
        }

        public void Print(string a)
        {
            Console.WriteLine(a);
        }
    }
    /// <summary>
    /// 接口
    /// </summary>
    public interface IMobile
    {
        void GetMobileType();
    }
    public class Nokia : MobilePhone, IMobile
    {
        public string c { get; set; }
        public override void Call()
        {
            Console.WriteLine("Nokia是一种手机品牌");
        }

        //public override void Callagain()
        //{
        //    Console.WriteLine("重写虚方法Callagain");
        //}
        public override void Callvirtual()
        {
            Console.WriteLine("重写虚方法Callvirtual");
        }

        //public void Print(string a)
        //{
        //    Console.WriteLine(a);
        //}

        public void GetMobileType()
        {
            Console.WriteLine("GetMobileType:Nokia");
        }

        public void ChangeStr(Nokia a)
        {
            a.c = "改变值";

        }
    }

    public static class MobileStatic
    {
        public static void GetMsg()
        {
            Console.WriteLine("获取信息");
        }

    }

    public class Xiaomi : MobilePhone
    {

        public override void Call()
        {
            throw new NotImplementedException();
        }
    }

    public class A
    {
        public static int X;
        static A()
        {
            X = B.Y + 1;
        }
    }
    public class B
    {
        public static int Y = A.X + 1;
        static B() { }

    }
     
}